home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-03-25 | 2.9 KB | 96 lines | [TEXT/CWIE] |
- // ===========================================================================
- // CNeuron.h ©1996 Timo Eloranta
- // ===========================================================================
- // An abstract neuron class - derived from LLink to be queueable
-
- #pragma once // Include this header only once
-
- #include "NS_Types.h"
-
- #include <LList.h> // PowerPlant list class
- #include <LLink.h> // PowerPlant link class
-
- class CNeuron; // Forward class declarations
- class CNeuralNet;
-
- typedef CNeuron * CNeuronPtr;
-
- class CNeuron : public LLink
- {
- protected:
- Uint16 mState; // Number of impulses received
- Uint16 mMaxState; // If mState gets bigger than this
- // the neuron will light up
-
- Uint16 mCol; // Location: column ( > 0 )
- Uint16 mRow; // Location: row ( > 0 )
-
- LList mNextOnes; // A list of the neurons to which
- // this neuron is connected to
-
- static CNeuralNet *sNet; // A pointer to the net which
- // owns this neuron (static!)
-
- // --- Drawing related attributes --- //
-
- Point mCenter; // Location on the screen
-
- Boolean mRedrawNeeded; // Has this neuron changed so
- // that it should be redrawn?
- Boolean mDestination; // Should this neuron be drawn
- // with a "yellow ring" around it?
- Boolean mConnDirty; // Are the connections in need
- // of redrawing?
- Boolean mConnLit; // Are the connections lit?
-
- Rect mConnRect; // The rectangle inside of which all
- // of the connected neurons are
- // (used when drawing connections)
-
- virtual void SetNeuronState( Uint16 inState );
-
- public:
- CNeuron();
- virtual ~CNeuron() {};
-
- virtual void IncState();
-
- virtual void SetNeuronPos( Uint16 inCol, Uint16 inRow );
- virtual void GetNeuronPos( Uint16 & outX, Uint16 & outY) const;
-
- virtual Boolean IsReceptor() const;
-
- virtual void AddToNeuronList( const CNeuronPtr inNeuronPtr );
- virtual Boolean IsConnectedTo( const CNeuronPtr inNeuronPtr );
-
- static void SetNet( CNeuralNet *inNet );
-
- // The following are pure virtual functions.
- // Concrete subclasses must override them!
-
- virtual void DoClickAction( Boolean inOptionKeyDown ) = 0;
- virtual Boolean ShouldLightUp() const = 0;
- virtual void DoLightUpAction() = 0;
- virtual void SetPostLightUpState() = 0;
-
- // --- Drawing related member functions --- //
-
- virtual void Draw( const Rect & inRect );
- virtual void ForceRedraw()
- { mRedrawNeeded = true; }
- virtual Boolean RedrawNeeded() const
- { return mRedrawNeeded; };
-
- virtual void SetDestinationFlag( Boolean inTrueOrFalse )
- { mDestination = inTrueOrFalse; };
-
- virtual void DrawConnections();
- virtual Boolean ConnectionsDirty() const
- { return mConnDirty; };
-
- virtual void SetCenterPoint( Point & inCenter )
- { mCenter = inCenter; };
- virtual void SetConnectionRect( Rect & inRect )
- { mConnRect = inRect; };
- };
-